package com.wenhao.newcode.huawei;

import java.util.Scanner;

/**
 * @author Wenhao Tong
 * @date 2021/7/15 下午9:44
 */
public class MainHJ2 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.nextLine();
        char c = scanner.next().charAt(0);
        int[] count = new int[128];
        for (int i = 0;i < s.length();i++) {
            count[s.charAt(i)]++;
        }
        if (c >= 'a') {
            System.out.println(count[c] + count[c - ('a' - 'A')]);
        } else {
            System.out.println(count[c] + count[c + ('a' - 'A')]);
        }
    }
}
